package com.tianhua.javs.client.enums;

/**
 * Description:javs内置的与Java原生关键字对应关键字枚举信息
 * date: 2022/2/9
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
public enum JavsKeyWardEnum implements KeyWardEnum{
    IF("if","javs脚本控制语句",true),
    IF_NOTEMPTY("ifnotempty","如果变量条件不为空",true),
    IF_NULL("ifnull","如果变量条件为null",true),
    IF_RET("ifret","如果条件满足为true则返回",true),
    IF_RETS("ifrets","如果条件满足为true则返回成功",true),
    IF_NULL_THROW("ifnullthorw","如果变量条件为null则抛出异常",true),

    EIF("eif","条件控制语句，如果条件满足则走else if逻辑",true),
    ELSE("else","条件控制语句,如果之前的条件都不满足则走else 逻辑",true),
    FORE("fore","循环控制语句,对于Java的增强for循环",true),
    FORI("fori","循环控制语句,对于Java的普通for循环",true),



    RET("ret","方法返回",true),
    RET_TRUE("rettrue","方法返回 true",true),
    RET_FALSE("retfalse","方法返回 false",true),


    ;
    private String code;
    private String desc;
    private Boolean withFunction;

    JavsKeyWardEnum(String code, String desc, Boolean withFunction){
        this.code = code;
        this.desc = desc;
        this.withFunction = withFunction;
    }

    @Override
    public String getKeyWardCode() {
        return code;
    }

    @Override
    public String getKeyWardDesc() {
        return desc;
    }

    @Override
    public boolean withFunction() {
        return false;
    }

    @Override
    public String templateCode() {
        return null;
    }


    /**
     * 判断是否是业务关键字
     * @param varCode
     * @return
     */
    public static boolean isJavsKeyWard(String varCode){
        for (JavsKeyWardEnum javsKeyWardEnum : JavsKeyWardEnum.values()){
            if(javsKeyWardEnum.getKeyWardCode().equals(varCode)){
                return true;
            }
        }
        return false;
    }
}
